package com.oncliedisk.administrator.Base;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.oncliedisk.administrator.adapter.TaskAdapter;
import com.oncliedisk.administrator.content.OnlineConfig;
import com.oncliedisk.administrator.onlinedisk.R;
import com.ypy.eventbus.EventBus;

/**
 * Created by Administrator on 2015/12/17.
 */
public class BaseTaskFragment extends Fragment implements AdapterView.OnItemLongClickListener {

    protected boolean isDown; //是否是下载页面
    protected TextView path; // 下载路径
    protected ListView listview; //listview
    protected TaskAdapter mAdapter; //适配器
    protected String mType; //本页面的类型
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_down, null);
        initWeight(view);
        initData();
        initListener();
        return view;
    }

    private void initListener() {
        listview.setOnItemLongClickListener(this);
    }

    /**
     * 初始化数据
     */
    private void initData() {
        EventBus.getDefault().register(this);
        if (isDown) {
            path.setVisibility(View.VISIBLE);
            path.setText(OnlineConfig.DOWN_DIRECTORY);
        }
        mType = isDown==true?OnlineConfig.TYPE_DOWN:OnlineConfig.TYPE_UP;
    }
    /**
     * 初始化控件
     *
     * @param view
     */
    private void initWeight(View view) {
        path = (TextView) view.findViewById(R.id.task_path);
        listview = (ListView) view.findViewById(R.id.task_lv);
    }

    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
        return false;
    }
}
